package com.wanjia.bpsapi.service.impl;

import com.wanjia.bpsapi.pojo.dto.DefaultDataDto;
import com.wanjia.bpsapi.pojo.entity.DefaultData;
import com.wanjia.bpsapi.mapper.DefaultDataMapper;
import com.wanjia.bpsapi.service.IDefaultDataService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.math.BigDecimal;
import java.util.List;

/**
 * <p>
 * 默认数据表 服务实现类
 * </p>
 *
 * @author wyn
 * @since 2023-02-13
 */
@Service
public class DefaultDataServiceImpl extends ServiceImpl<DefaultDataMapper, DefaultData> implements IDefaultDataService {

    @Autowired
    DefaultDataMapper defaultDataMapper;

    public int updateData(DefaultData defaultData){
        Long uid = defaultData.getUid();
        BigDecimal gross = defaultData.getGross();
        BigDecimal businessExpense = defaultData.getBusinessExpense();
        BigDecimal discount = defaultData.getDiscount();
        int i = defaultDataMapper.updateData(uid,gross,discount,businessExpense);
        return i;
    }

    public int deleteData(Integer id){
        int i = defaultDataMapper.deleteById(id);
        return i;
    }

    @Override
    public List<DefaultDataDto> getData(Integer uid, Integer pageNo, Integer pageSize) {
        List<DefaultDataDto> data = defaultDataMapper.getData(uid, pageNo, pageSize);
        return data;
    }

}
